<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>LH</title><meta name="author" content="lihao,1767359165@qq.com"><meta name="copyright" content="lihao"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="千磨万击还坚劲，任尔东西南北风">
<meta property="og:type" content="website">
<meta property="og:title" content="LH">
<meta property="og:url" content="https://lh521.top/index.html">
<meta property="og:site_name" content="LH">
<meta property="og:description" content="千磨万击还坚劲，任尔东西南北风">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://lh521.top/img/touxiang.png">
<meta property="article:author" content="lihao">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://lh521.top/img/touxiang.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://lh521.top/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2021-03-14 18:29:43'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><meta name="generator" content="Hexo 5.3.0"><link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="iron-container iron-circle"><div class="iron-box1 iron-circle iron-center"></div><div class="iron-box2 iron-circle iron-center"></div><div class="iron-box3 iron-circle iron-center"></div><div class="iron-box4 iron-circle iron-center"></div><div class="iron-box5 iron-circle iron-center"></div><div class="iron-box6 iron-circle"><div class="iron-coil" style="--i: 0"></div><div class="iron-coil" style="--i: 1"></div><div class="iron-coil" style="--i: 2"></div><div class="iron-coil" style="--i: 3"></div><div class="iron-coil" style="--i: 4"></div><div class="iron-coil" style="--i: 5"></div><div class="iron-coil" style="--i: 6"></div><div class="iron-coil" style="--i: 7"></div></div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" data-lazy-src="/img/touxiang.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">11</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">6</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">6</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/bb/"><i class="fa-fw fas fa-music"></i><span> 点点滴滴</span></a></li><li><a class="site-page" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page" href="/xingkong/"><i class="fa-fw fa fa-heartbeat"></i><span> 星空物语</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div id="body-wrap"><header class="full_page" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">LH</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/bb/"><i class="fa-fw fas fa-music"></i><span> 点点滴滴</span></a></li><li><a class="site-page" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page" href="/xingkong/"><i class="fa-fw fa fa-heartbeat"></i><span> 星空物语</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">LH</h1><div id="site-subtitle"><span id="subtitle"></span></div><div id="site_social_icons"><a class="social-icon" href="https://github.com/LHNB521" target="_blank" title="Github"><i class="fab fa-github"></i></a></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/03/09/es6-shu-zhi-de-kuo-zhan/" title="ES6数值的扩展">     <img class="post_bg" data-lazy-src="https://i.loli.net/2021/03/12/FwCNIhKedQUOlrj.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ES6数值的扩展"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/09/es6-shu-zhi-de-kuo-zhan/" title="ES6数值的扩展">ES6数值的扩展</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-03-09T02:44:54.000Z" title="发表于 2021-03-09 10:44:54">2021-03-09</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/ES6/">ES6</a></span></div><div class="content">1.二进制和八进制的表示方法ES6提供了二进制和八进制数值的新的方法，分别用前缀0b（或者0B）和0o（或者00）表示。
2.Number.isFinite(),Number.isNaN()ES6在Number对象上，新提供了Number.isFinite()和Number.isNaN()两个方法。Number.isFinite()用来检查一个数值是否为有限的（finite），即不是Infinity。
3.Number.parseInt(),Number.parseFloat()ES6将全局方法parseInt()和parseFloat()，一直到Number对象上面，行为保持不变。
1234567// ES5的写法parseInt(&#x27;12.34&#x27;) // 12parseFloat(&#x27;123.45#&#x27;) // 123.45// ES6的写法Number.parseInt(&#x27;12.34&#x27;) // 12Number.parseFloat(&#x27;123.45#&#x27;) // 123.45
这样的做法的目的，是逐步减少全局 ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/03/09/js-zhong-reduce-de-yong-fa/" title="js中reduce()的用法">     <img class="post_bg" data-lazy-src="https://i.loli.net/2021/03/12/cPIrwnNEviljtzR.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="js中reduce()的用法"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/09/js-zhong-reduce-de-yong-fa/" title="js中reduce()的用法">js中reduce()的用法</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-03-09T02:00:00.000Z" title="发表于 2021-03-09 10:00:00">2021-03-09</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/js/">js</a></span></div><div class="content">定义和用法reduce()方法接受一个函数作为累加器，数组中的每个值（从左到右）开始缩减，最终计算为一个值。reduce()可以作为一个高阶函数，用于函数的compose。注意：reduce()对于空数组是不会执行回调函数的。
语法arr.reduce(function(total, currentValue, currentIndex, arr)&#123;&#125;, initialValue); 
参数


参数
描述









function(total,currentValue, index,arr) | 必需。用于执行每个数组元素的函数。函数参数： |  ||  ||  | 参数 | 描述 ||  | total | 必需。初始值，或者计算结束后的返回值 ||  | currentValue | 必需。当前正在处理的数组元素 ||  | currentIndex | 可选。当前元素索引 ||  | arr | 可选。当前元素所属的数组对象 || initialValue | 可选。传递给函数的初始值 |  |
看上去挺TM复杂的，其实常用的参数只有两个：tota ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/01/20/html-ji-chu-zhi-shi/" title="HTML基础知识">     <img class="post_bg" data-lazy-src="https://i.loli.net/2021/03/12/ST85d6qtGrbC3pA.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="HTML基础知识"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/01/20/html-ji-chu-zhi-shi/" title="HTML基础知识">HTML基础知识</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-01-20T07:44:15.000Z" title="发表于 2021-01-20 15:44:15">2021-01-20</time></span></div><div class="content">HTML基础知识HTML结构HTML的结构一般包括&lt;head&gt;标签和&lt;body&gt;标签，&lt;head&gt;和&lt;body&gt;这两个标记符分别表示网页的头部和正文。头部中可包含页面的标题、关键词、描述说明等内容，他本身不作为内容显示，但影响网页显示的效果。&lt;body&gt;&lt;/body&gt;当中是网页实际显示的内容，正文标记符又被称为实体标记。
实例12345678910&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;页面标题&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;我的第一个标题&lt;/h1&gt;&lt;p&gt;我的第一个段落。&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;

DOCTYPE声明了文档的类型
&lt;html&gt;标签是HTML页面的根元素，该标签的结束标志位&lt;/html&gt;、
&lt;head&gt;标签包含了文档的元数据（meta），如&lt;meta ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/01/14/es6-ji-chu-new-set/" title="ES6 基础new Set">     <img class="post_bg" data-lazy-src="https://i.loli.net/2021/03/12/xTebED5CWjHhamu.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ES6 基础new Set"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/01/14/es6-ji-chu-new-set/" title="ES6 基础new Set">ES6 基础new Set</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-01-14T08:17:26.000Z" title="发表于 2021-01-14 16:17:26">2021-01-14</time></span></div><div class="content">Es6 基础之 new setSet对象存储的值总是唯一的Set对象方法



方法
描述



add
添加某个值，返回Set对象本身


clear
删除所有的键/值对，没有返回结果


delete
删除某个键，返回true、如果删除失败，返回false


forEach
对每个元素执行指定操作


has
返回一个布尔值，表示某个键是否在当前Set对象之中


Set对象作用
数组去重12345var arr = [1,2,3,4,5];[...new Set(arr)];    // [1,2,3,4,5]Array.from(new Set(arr)); //[1,2,3,4,5][...new Set(&#x27;ababbc&#x27;)].join(&#x27;&#x27;);   //&quot;abc&quot;字符串去重new Set(&#x27;ice doughnut&#x27;); //Set(11) &#123;&quot;i&quot;, &quot;c&quot;, &quot;e&quot;, &quot; &quot;, &quot;d&quo ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/01/14/es6-zhi-array.from-fang-fa/" title="ES6之Array.frome()方法">     <img class="post_bg" data-lazy-src="https://i.loli.net/2021/03/12/cPIrwnNEviljtzR.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ES6之Array.frome()方法"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/01/14/es6-zhi-array.from-fang-fa/" title="ES6之Array.frome()方法">ES6之Array.frome()方法</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-01-14T06:36:01.000Z" title="发表于 2021-01-14 14:36:01">2021-01-14</time></span></div><div class="content">ES6之Array.from()方法Array.from()方法就是将一个类数组对象或者可遍历对象转换成一个真正的数组。那么什么是类数组对象呢？所谓类数组对象，最基本的要求就是具有length属性的对象。
1.将类数组对象转换为真正的数组：123456789let arrayLike = &#123;	0:&#x27;tom&#x27;,	1:&#x27;22&#x27;,	2:&#x27;男&#x27;,	3:[&#x27;jane&#x27;,&#x27;john&#x27;,&#x27;Mary&#x27;],	&#x27;length&#x27;:4&#125;let arr = Array.from(arrayLike)console.log(arr)     //[&#x27;tom&#x27;,&#x27;22&#x27;,&#x27;男&#x27;,[&#x27;jane&#x27;,&#x27;john&#x27;,&#x27;Mary&#x27;]]
那么，如果将上面代码中length属性去掉呢？实践证明，答案会是一个长度为0的空数组。这里将代码再改一下，就是具有l ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/01/05/ji-suan-ji-wang-luo-yuan-li/" title="计算机网络原理">     <img class="post_bg" data-lazy-src="https://i.loli.net/2021/03/12/ST85d6qtGrbC3pA.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="计算机网络原理"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/01/05/ji-suan-ji-wang-luo-yuan-li/" title="计算机网络原理">计算机网络原理</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-01-05T11:09:33.000Z" title="发表于 2021-01-05 19:09:33">2021-01-05</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA/">计算机</a></span></div><div class="content">计算机网络主要指的是TCP/IP协议栈
闲聊

TCP/IP是互联网的基石，互联网时代的最伟大的发明。前端后端都有涉及TCP/IP技术栈有一部分都隐藏于操作系统内核态，总有藏着掖着，老是见不得人，当然容易被遗忘。



TCP/IP协议体系的认知


一些概念
内核态用户态应用层（接触较多）数据链路层数据传输对等






数据链路层


以太网帧的格式
MTU（最大传输单元）概念
ARP协议、RARP协议（即地址解析和逆地址解析）
一般归入链路层，网络和链路层的中间协议报文格式IP和MAC地址互查ARP缓存






网络层


掌握IP首部格式：如16位分片标识、DF不分片标志、MF更多分片标志、13位片偏移，8位生存时间TTL，16位的首部检验和等等
掌握IP分片
掌握IP选路（路由表）
掌握ICMP协议
报文格式报文的两大分类：查询+交错

2种查询报文+5种差错报文







传输层


掌握UDP协议：包括特点+首部各个字段
掌握TCP协议：特点+首部字段+可靠机制
TCP链接控制机制：三次握手、四次挥手、同时打开、同时关闭、半关闭
TCP流量控制机制：滑动窗口、慢 ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/01/05/shu-zu-bian-ping-hua/" title="数组扁平化">     <img class="post_bg" data-lazy-src="https://i.loli.net/2021/03/12/ST85d6qtGrbC3pA.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="数组扁平化"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/01/05/shu-zu-bian-ping-hua/" title="数组扁平化">数组扁平化</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-01-05T10:58:37.000Z" title="发表于 2021-01-05 18:58:37">2021-01-05</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/JavaSctipt/">JavaSctipt</a></span></div><div class="content">数组扁平化数组扁平化是指将多维数组变为一维数组：[1,[2,3,[4,5]]]   -----&gt;  [1,2,3,4,5]
实现1.reduce遍历数组每一项，若值为数组则递归遍历，否则concat。
12345function flatten(arr)&#123;	return arr.reduce((result,item)=&gt;&#123;		return result.concat(Array.isArray(item)?flattten(item):item);	&#125;,[]);&#125;
reduce是数组的一种方法，它接受一个函数作为累加器，数组中的每个值（从左到右）开始缩减，最终计算一个值。reduce包含两个参数：回调函数，传给total的初始值。
1234//求数组的各项值相加的和arr.reduce((total,item)=&gt;&#123; //total为之前的计算结果，item为数组的各项值	return total+item;&#125;,0)
2.toString&amp;split调用数组的toString方法，将数组变为字符串然 ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/01/02/css-ding-wei-xiang-jie/" title="CSS定位详解">     <img class="post_bg" data-lazy-src="https://i.loli.net/2021/03/12/cPIrwnNEviljtzR.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="CSS定位详解"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/01/02/css-ding-wei-xiang-jie/" title="CSS定位详解">CSS定位详解</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-01-02T11:44:54.000Z" title="发表于 2021-01-02 19:44:54">2021-01-02</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/CSS/">CSS</a></span></div><div class="content">CSS定位详解CSS有个重要的基本属性，前端开发必须掌握：display 和positiondisplay属性指定网页的布局。两个重要的布局：弹性布局flex和网格布局grid。
一、position属性的作用position属性用来指定一个元素在网页上的位置，一共有5种定位方式，即position属性的主要五个值。

static
relative
fixed
absolute
sticky

二、static属性值static是position属性的默认值。如果省略position属性，浏览器就认为该元素是static定位。注意：static定位所导致的元素位置，是浏览器自主决定的，所以这时top、bootom、left、right这四个属性无效。
三、relative，absolute，fixedrelative、absolute、fixed这三个属性值有一个共同点，都是对于某个基点的定位，不同之处仅仅在于基点不同。所以，只要理解了它们的基点是什么，就很容易掌握这三个属性值。这三种定位都不会对其他元素位置产生影响，因此元素之间可能 产生重叠。
3.1 relative属性值rel ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/01/02/javascript-shu-zu/" title="JavaScript变量、数组">     <img class="post_bg" data-lazy-src="https://i.loli.net/2021/03/12/7aMv4AwHZNXdlW3.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JavaScript变量、数组"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/01/02/javascript-shu-zu/" title="JavaScript变量、数组">JavaScript变量、数组</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-01-02T11:22:00.000Z" title="发表于 2021-01-02 19:22:00">2021-01-02</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/JavaScript/">JavaScript</a></span></div><div class="content">JS变量、数组一，变量1.ECMAScript的变量是松散型变量。
松散型变量：可以用来保存任何类型的数据，换句话来说，每个变量仅仅是一个用于保存的占位符而而已。
定义变量要是用var操作符。（var是一个关键字），后跟变量名（既是一个标识符）。如下：
1var message;
改代码就是定义了一个名字为message的变量，该变量可以保存任何类型的数据。注意：既用var操作符定义的变量将成为该变量的作用域的局部变量。如果在函数中使用var定义一个变量，那么这个变量在函数退出后就会被销毁。例如;错误例子：
12345function test()&#123;  var message=&quot;hi&quot;;//局部变量&#125;test();alert(message);//错误
正确例子：
12345function test()&#123;  var message=&quot;hi&quot;;  alert(message);&#125;test();
二.数据类型1.ECMAScript中有5中简单的数据类型（也称为基本数据类型）；5种数据类型:Undefind, ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/01/02/htmldom/" title="HTMLDOM">     <img class="post_bg" data-lazy-src="https://i.loli.net/2021/03/12/FwCNIhKedQUOlrj.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="HTMLDOM"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/01/02/htmldom/" title="HTMLDOM">HTMLDOM</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-01-02T11:10:00.000Z" title="发表于 2021-01-02 19:10:00">2021-01-02</time></span></div><div class="content">HTML DOM 简介HTML DOM定义了访问和操作HTML文档标准
如果想要学习该知识用该具备的知识：

HTML
CSS
JavaScript

什么是DOM？DOM是W3C（万维网联盟）的标准。
DOM定义了访问HTML和XML文档的标准：
“W3C文档对象模型（DOM）是中立于平台和语言的接口，它允许程序和脚本动态地访问和更新文档的内容、结构和样式。”
W3C DOM标准被分为3个不同的部分：

核心DOM - 针对任何结构化文档的标准模型
XML DOM - 针对XML文档的标准模型
HTML DOM - 针对HTML文档的标准模型

什么是HTML DOM？HTML DOM是：

HTML的标准对象模型
HTML的标准编程接口
W3C标准

HTML DOM定义了所有HTML元素的对象和属性，以及访问他们的方法。
HTML DOM是关于如何获取、修改、添加或删除HTML元素的标准。
HTML DOM节点在HTML DOM中，所有事物都是节点。DOM是被视为节点树的HTML。
DOM节点根据W3C的HTML DOM标准，HTML文档中的所有内容都是节点：

整个文档是一个文 ...</div></div></div><nav id="pagination"><div class="pagination"><span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="extend next" rel="next" href="/page/2/"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="/img/touxiang.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">lihao</div><div class="author-info__description">千磨万击还坚劲，任尔东西南北风</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">11</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">6</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">6</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/LHNB521"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/LHNB521" target="_blank" title="Github"><i class="fab fa-github"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/03/09/es6-shu-zhi-de-kuo-zhan/" title="ES6数值的扩展"><img data-lazy-src="https://i.loli.net/2021/03/12/FwCNIhKedQUOlrj.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ES6数值的扩展"/></a><div class="content"><a class="title" href="/2021/03/09/es6-shu-zhi-de-kuo-zhan/" title="ES6数值的扩展">ES6数值的扩展</a><time datetime="2021-03-09T02:44:54.000Z" title="发表于 2021-03-09 10:44:54">2021-03-09</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/03/09/js-zhong-reduce-de-yong-fa/" title="js中reduce()的用法"><img data-lazy-src="https://i.loli.net/2021/03/12/cPIrwnNEviljtzR.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="js中reduce()的用法"/></a><div class="content"><a class="title" href="/2021/03/09/js-zhong-reduce-de-yong-fa/" title="js中reduce()的用法">js中reduce()的用法</a><time datetime="2021-03-09T02:00:00.000Z" title="发表于 2021-03-09 10:00:00">2021-03-09</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/20/html-ji-chu-zhi-shi/" title="HTML基础知识"><img data-lazy-src="https://i.loli.net/2021/03/12/ST85d6qtGrbC3pA.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="HTML基础知识"/></a><div class="content"><a class="title" href="/2021/01/20/html-ji-chu-zhi-shi/" title="HTML基础知识">HTML基础知识</a><time datetime="2021-01-20T07:44:15.000Z" title="发表于 2021-01-20 15:44:15">2021-01-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/14/es6-ji-chu-new-set/" title="ES6 基础new Set"><img data-lazy-src="https://i.loli.net/2021/03/12/xTebED5CWjHhamu.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ES6 基础new Set"/></a><div class="content"><a class="title" href="/2021/01/14/es6-ji-chu-new-set/" title="ES6 基础new Set">ES6 基础new Set</a><time datetime="2021-01-14T08:17:26.000Z" title="发表于 2021-01-14 16:17:26">2021-01-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/14/es6-zhi-array.from-fang-fa/" title="ES6之Array.frome()方法"><img data-lazy-src="https://i.loli.net/2021/03/12/cPIrwnNEviljtzR.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ES6之Array.frome()方法"/></a><div class="content"><a class="title" href="/2021/01/14/es6-zhi-array.from-fang-fa/" title="ES6之Array.frome()方法">ES6之Array.frome()方法</a><time datetime="2021-01-14T06:36:01.000Z" title="发表于 2021-01-14 14:36:01">2021-01-14</time></div></div></div></div><div class="card-widget" id="card-newest-comments"><div class="item-headline"><i class="fas fa-bolt"></i><span>最新评论</span></div><div class="aside-list"><span>正在加载中...</span></div></div><div class="card-widget card-categories"><div class="item-headline">
            <i class="fas fa-folder-open"></i>
            <span>分类</span>
            
            </div>
            <ul class="card-category-list" id="aside-cat-list">
            <li class="card-category-list-item "><a class="card-category-list-link" href="/categories/CSS/"><span class="card-category-list-name">CSS</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/ES6/"><span class="card-category-list-name">ES6</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/JavaScript/"><span class="card-category-list-name">JavaScript</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/JavaSctipt/"><span class="card-category-list-name">JavaSctipt</span><span class="card-category-list-count">2</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/js/"><span class="card-category-list-name">js</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA/"><span class="card-category-list-name">计算机</span><span class="card-category-list-count">1</span></a></li>
            </ul></div><div class="card-widget card-tags"><div class="item-headline"><i class="fas fa-tags"></i><span>标签</span></div><div class="card-tag-cloud"><a href="/tags/CSS/" style="font-size: 1.1em; color: rgb(60, 124, 39)">CSS</a><a href="/tags/JavaScript/" style="font-size: 1.3em; color: rgb(18, 149, 61)">JavaScript</a><a href="/tags/js/" style="font-size: 1.5em; color: rgb(77, 135, 76)">js</a><a href="/tags/ES6/" style="font-size: 1.1em; color: rgb(192, 66, 88)">ES6</a><a href="/tags/html/" style="font-size: 1.1em; color: rgb(123, 116, 90)">html</a><a href="/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/" style="font-size: 1.1em; color: rgb(4, 7, 86)">计算机网络</a></div></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>归档</span></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/03/"><span class="card-archive-list-date">三月 2021</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/01/"><span class="card-archive-list-date">一月 2021</span><span class="card-archive-list-count">8</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2020/12/"><span class="card-archive-list-date">十二月 2020</span><span class="card-archive-list-count">1</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">11</div></div><div class="webinfo-item"><div class="item-name">已运行时间 :</div><div class="item-count" id="runtimeshow" data-publishDate="2020-12-11T16:00:00.000Z"></div></div><div class="webinfo-item"><div class="item-name">本站访客数 :</div><div class="item-count" id="busuanzi_value_site_uv"></div></div><div class="webinfo-item"><div class="item-name">本站总访问量 :</div><div class="item-count" id="busuanzi_value_site_pv"></div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2021-03-14T10:29:43.652Z"></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By lihao</div><div class="footer_custom_text">Hi, welcome to my blog!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (true){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><div class="js-pjax"><script async="async">var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> {preloader.endLoading()})
setTimeout(function(){preloader.endLoading();}, 3000);</script></div><div class="js-pjax"><script>function subtitleType () {
  if (true) { 
    var typed = new Typed("#subtitle", {
      strings: "努力&#44;加油,Never put off till tomorrow what you can do today".split(","),
      startDelay: 300,
      typeSpeed: 150,
      loop: false,
      backSpeed: 50
    })
  } else {
    document.getElementById("subtitle").innerHTML = '努力&#44;加油'
  }
}

if (true) {
  if (typeof Typed === 'function') {
    subtitleType()
  } else {
    getScript('https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js').then(subtitleType)
  }
} else {
  subtitleType()
}</script></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"]):not([href="/bb/"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  if (typeof gtag === 'function') {
    gtag('config', '', {'page_path': window.location.pathname});
  }

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})


document.addEventListener('pjax:send', function () {
  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>